import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'element-ui/lib/theme-chalk/index.css'
import element from './element/index'
import './assets/reset.css'
import VeLine from 'v-charts/lib/line.common'
import VeBar from 'v-charts/lib/bar.common'
import VePie from 'v-charts/lib/pie.common'
import VeHistogram from 'v-charts/lib/histogram.common'

import http from './http.js'
import upload from './upload.js'
import { JSEncrypt } from 'jsencrypt'

import JsonExcel from 'vue-json-excel'
Vue.component('downloadExcel', JsonExcel)

Vue.component(VeLine.name, VeLine)
Vue.component(VeBar.name, VeBar)
Vue.component(VePie.name, VePie)
Vue.component(VeHistogram.name, VeHistogram)
Vue.config.productionTip = false
Vue.prototype.http = http
Vue.prototype.upload = upload
Vue.use(element)

let publickey = '-----BEGIN PUBLIC KEY-----MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEArVzwFev/KQb15oUk8AHXcGkVpNXExp3HU/l3BxafOauO9dvSNstYS8NOkRiWpr7ZoBsTivi2TpvquG+4Qr2WMfjEFy/fGwE/6plysO0JTm2RtiQJt4bpnawevmmBffACblhl/bMs/vDzKuW5kySRQwtWwjDku1OjXkA0IMVBb+uu3/yDOyP5BJ1PzEQOSLrA0N8kbCZK08x0HTbSCjV581LYqym40eokDDhVS644cuecfsG1DyaSu994CSaRJOUaQkao8/gvunXMLCBsD7QlXOoQ1fJ2ZlElyRsbutaA0ryhJoYZbNTjzV885ZggEWH9d6oyZ+5F0ge3HQuykL3AdGIl86c1+HpWmu3nAfHR6gx2cmrCCra46/knUEeLB8rkSjViqctqh7ofWVmilKmupkdqlT1/Z4obCuyEhjO0+dYzgR/6evyB+puaJJfzZ6aoHKkQJYrmvqbo+xMU4AyXa4xa8D9wVEAM+SED3mv1PFvemViJ2pDjc5Y1hCXBEW1AyA5CFr4aOxkZ65Il0nIl5+n/hjfEIYeT9vEgGaNC8JgOCo9TNansrmIlDZ5s/SA8XkYt9BJNx774gI8HPdTqOGKtiDHsONrvwYP6EMlHHgYoLS9kuae77/C33oEwTswfT9v3AwhogPnk2ILr+zDfjldK9DtCjqEEbipHFU+AYjsCAwEAAQ==-----END PUBLIC KEY-----'
// JSEncrypt加密
Vue.prototype.$getCode = function (password) {
  // new 一个对象
  let encrypt = new JSEncrypt()
  // 后台给的公钥
  encrypt.setPublicKey(publickey)
  // password是需要加密的数据
  let data = encrypt.encrypt(password)
  return data
}
// router.beforeEach((to, from, next) => {
//     if (to.matched.length === 0) {
//         from.path ? next({ path: from.path }) : next('/')
//     } else {
//         if (to.meta.requireAuth) { // 判断该路由是否需要登录权限
//             if (sessionStorage.getItem('token')) { // 通过vuex state获取当前的token是否存在
//                 next()
//             } else {
//                 next({
//                     path: '/login'
//                         // query: { redirect: to.fullPath } // 将跳转的路由path作为参数，登录成功后跳转到该路由
//                 })
//             }
//         } else {
//             next()
//         }
//     }
// })
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
